﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Modulos/ModuloVenta/VistaControl/MasterPageVenta.master"
    AutoEventWireup="true" CodeFile="AdmProductoVenta.aspx.cs" Inherits="Modulos_ModuloVenta_VistaControl_Default" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <h2>
        Administrar Producto
    </h2>
    <p>
        Aquí podrá ingresar nuevos productos y editar los que existan
    </p>
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
        AutoGenerateColumns="False" DataKeyNames="PRD_VNT_COD" DataSourceID="SqlDataSource1"
        Height="16px" Width="425px">
        <Columns>
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
            <asp:BoundField DataField="PRD_VNT_COD" HeaderText="Código" InsertVisible="False"
                ReadOnly="True" SortExpression="PRD_VNT_COD" />
            <asp:BoundField DataField="LSB_COD" HeaderText="Tipo" SortExpression="LSB_COD" />
            <asp:BoundField DataField="PRD_VNT_NMB" HeaderText="Nombre" SortExpression="PRD_VNT_NMB" />
            <asp:BoundField DataField="PRD_VNT_STOCK" HeaderText="Stock" SortExpression="PRD_VNT_STOCK" />
            <asp:BoundField DataField="PRD_VNT_DESC" HeaderText="Descripción" SortExpression="PRD_VNT_DESC" />
            <asp:BoundField DataField="PRD_VNT_PRC" HeaderText="Precio" SortExpression="PRD_VNT_PRC" />
        </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConflictDetection="CompareAllValues"
        ConnectionString="<%$ ConnectionStrings:AppCeiiConnectionString %>" DeleteCommand="DELETE FROM [PRODUCTO_VENTA] WHERE [PRD_VNT_COD] = @original_PRD_VNT_COD AND [LSB_COD] = @original_LSB_COD AND [PRD_VNT_NMB] = @original_PRD_VNT_NMB AND [PRD_VNT_STOCK] = @original_PRD_VNT_STOCK AND (([PRD_VNT_DESC] = @original_PRD_VNT_DESC) OR ([PRD_VNT_DESC] IS NULL AND @original_PRD_VNT_DESC IS NULL)) AND [PRD_VNT_PRC] = @original_PRD_VNT_PRC"
        InsertCommand="INSERT INTO [PRODUCTO_VENTA] ([LSB_COD], [PRD_VNT_NMB], [PRD_VNT_STOCK], [PRD_VNT_DESC], [PRD_VNT_PRC]) VALUES (@LSB_COD, @PRD_VNT_NMB, @PRD_VNT_STOCK, @PRD_VNT_DESC, @PRD_VNT_PRC)"
        OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT * FROM [PRODUCTO_VENTA]"
        UpdateCommand="UPDATE [PRODUCTO_VENTA] SET [LSB_COD] = @LSB_COD, [PRD_VNT_NMB] = @PRD_VNT_NMB, [PRD_VNT_STOCK] = @PRD_VNT_STOCK, [PRD_VNT_DESC] = @PRD_VNT_DESC, [PRD_VNT_PRC] = @PRD_VNT_PRC WHERE [PRD_VNT_COD] = @original_PRD_VNT_COD AND [LSB_COD] = @original_LSB_COD AND [PRD_VNT_NMB] = @original_PRD_VNT_NMB AND [PRD_VNT_STOCK] = @original_PRD_VNT_STOCK AND (([PRD_VNT_DESC] = @original_PRD_VNT_DESC) OR ([PRD_VNT_DESC] IS NULL AND @original_PRD_VNT_DESC IS NULL)) AND [PRD_VNT_PRC] = @original_PRD_VNT_PRC">
        <DeleteParameters>
            <asp:Parameter Name="original_PRD_VNT_COD" Type="Decimal" />
            <asp:Parameter Name="original_LSB_COD" Type="Decimal" />
            <asp:Parameter Name="original_PRD_VNT_NMB" Type="String" />
            <asp:Parameter Name="original_PRD_VNT_STOCK" Type="Int32" />
            <asp:Parameter Name="original_PRD_VNT_DESC" Type="String" />
            <asp:Parameter Name="original_PRD_VNT_PRC" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="LSB_COD" Type="Decimal" />
            <asp:Parameter Name="PRD_VNT_NMB" Type="String" />
            <asp:Parameter Name="PRD_VNT_STOCK" Type="Int32" />
            <asp:Parameter Name="PRD_VNT_DESC" Type="String" />
            <asp:Parameter Name="PRD_VNT_PRC" Type="Int32" />
            <asp:Parameter Name="original_PRD_VNT_COD" Type="Decimal" />
            <asp:Parameter Name="original_LSB_COD" Type="Decimal" />
            <asp:Parameter Name="original_PRD_VNT_NMB" Type="String" />
            <asp:Parameter Name="original_PRD_VNT_STOCK" Type="Int32" />
            <asp:Parameter Name="original_PRD_VNT_DESC" Type="String" />
            <asp:Parameter Name="original_PRD_VNT_PRC" Type="Int32" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="LSB_COD" Type="Decimal" />
            <asp:Parameter Name="PRD_VNT_NMB" Type="String" />
            <asp:Parameter Name="PRD_VNT_STOCK" Type="Int32" />
            <asp:Parameter Name="PRD_VNT_DESC" Type="String" />
            <asp:Parameter Name="PRD_VNT_PRC" Type="Int32" />
        </InsertParameters>
    </asp:SqlDataSource>
    <asp:FormView ID="FormView1" runat="server" DataKeyNames="PRD_VNT_COD" DataSourceID="SqlDataSource1">
        <EditItemTemplate>
            PRD_VNT_COD:
            <asp:Label ID="PRD_VNT_CODLabel1" runat="server" Text='<%# Eval("PRD_VNT_COD") %>' />
            <br />
            LSB_COD:
            <asp:TextBox ID="LSB_CODTextBox" runat="server" Text='<%# Bind("LSB_COD") %>' />
            <br />
            PRD_VNT_NMB:
            <asp:TextBox ID="PRD_VNT_NMBTextBox" runat="server" Text='<%# Bind("PRD_VNT_NMB") %>' />
            <br />
            PRD_VNT_STOCK:
            <asp:TextBox ID="PRD_VNT_STOCKTextBox" runat="server" Text='<%# Bind("PRD_VNT_STOCK") %>' />
            <br />
            PRD_VNT_DESC:
            <asp:TextBox ID="PRD_VNT_DESCTextBox" runat="server" Text='<%# Bind("PRD_VNT_DESC") %>' />
            <br />
            PRD_VNT_PRC:
            <asp:TextBox ID="PRD_VNT_PRCTextBox" runat="server" Text='<%# Bind("PRD_VNT_PRC") %>' />
            <br />
            <a href="javascript:__doPostBack('ctl01$UpdateButton','')">Nuevo</a>&nbsp;<asp:LinkButton
                ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                Text="Cancelar" />
        </EditItemTemplate>
        <InsertItemTemplate>
            <table style="width: 100%;">
                <tr>
                    <td style="width: 57px">
                        Stock
                    </td>
                    <td style="width: 3px">
                        :
                    </td>
                    <td>
                        <asp:TextBox ID="PRD_VNT_STOCKTextBox" runat="server" Text='<%# Bind("PRD_VNT_STOCK") %>' />
                    </td>
                </tr>
                <tr>
                    <td style="width: 57px">
                        Descripción
                    </td>
                    <td style="width: 3px">
                        :
                    </td>
                    <td>
                        <asp:TextBox ID="PRD_VNT_DESCTextBox" runat="server" Text='<%# Bind("PRD_VNT_DESC") %>' />
                    </td>
                </tr>
                <tr>
                    <td style="width: 57px">
                        Tipo
                    </td>
                    <td style="width: 3px">
                        :
                    </td>
                    <td>
                        <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource1"
                            DataTextField="LSB_NMB" DataValueField="LSB_COD" SelectedValue='<%# Bind("LSB_COD") %>'>
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td style="width: 57px">
                        Nombre
                    </td>
                    <td style="width: 3px">
                        :
                    </td>
                    <td>
                        <asp:TextBox ID="PRD_VNT_NMBTextBox" runat="server" Text='<%# Bind("PRD_VNT_NMB") %>' />
                        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:AppCeiiConnectionString %>"
                            SelectCommand="SELECT [LSB_COD], [LSB_NMB], [LSB_STOCK] FROM [LISTA_STOCK_BASE]">
                        </asp:SqlDataSource>
                    </td>
                </tr>
                <tr>
                    <td style="width: 57px">
                        Precio
                    </td>
                    <td style="width: 3px">
                        :
                    </td>
                    <td>
                        <asp:TextBox ID="PRD_VNT_PRCTextBox" runat="server" Text='<%# Bind("PRD_VNT_PRC") %>' />
                    </td>
                </tr>
            </table>
            <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
                Text="Insertar" />
            &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False"
                CommandName="Cancel" Text="Cancelar" />
            <br />
        </InsertItemTemplate>
        <ItemTemplate>
            <asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" CommandName="New"
                Text="Nuevo Producto" />
        </ItemTemplate>
        <EmptyDataTemplate>
            <asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" CommandName="New"
                Text="Nuevo Producto" />
        </EmptyDataTemplate>
    </asp:FormView>
</asp:Content>
